package cn.study.hashMapTest.bitmodel;

/**
 * @author ：大佳
 * @version: V1.0
 * @description : 位运算与取模运算的效率对比 new
 */
public class ModVsBitwise {
    public static void main(String[] args) {

        int number = 100000;
        int a = 1;
        long start = System.currentTimeMillis();
        for(int i = number ;i<Integer.MAX_VALUE ; i++) {
            a = a & i;
        }
        System.out.println("位运算%运算耗时：" + (System.currentTimeMillis() - start) + "毫秒");

        a = 1;
        start = System.currentTimeMillis();
        for(int i = number ;i<Integer.MAX_VALUE ; i++) {
            a %= i;
        }
        System.out.println("取模%运算耗时：" + (System.currentTimeMillis() - start) + "毫秒");
    }
}
